# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2023年03月21日
"""
import openpyxl

myBook=openpyxl.load_workbook('管理费用表.xlsx',data_only=True)
mySheet=myBook.active
myNewBook=openpyxl.Workbook()
myNewSheet=myNewBook.active
myNewSheet.title='管理费用表'
myNewSheet.append(['月份','费用分类','金额合计'])
myRows=list(mySheet.values)[1:]
myDict={}
for myRow in myRows:
	if myRow[2] in myDict.keys():
		myDict[myRow[2]]+=[myRow]
	else:
		myDict[myRow[2]]=[myRow]

for myType in myDict.keys():
	mySum=sum([myRow[3] for myRow in myDict[myType]])
	myNewSheet.append(['12月份',myType,mySum])

myNewBook.save('结果表-管理费用表.xlsx')

